.class public Lcom/glympse/platform/Reflection$_Service;
.super Ljava/lang/Object;
.source "Reflection.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/glympse/platform/Reflection;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x9
    name = "_Service"
.end annotation


# static fields
.field private static ms_fLoaded:Z

.field private static ms_oMethod_setForeground:Ljava/lang/reflect/Method;

.field private static ms_oMethod_startForeground:Ljava/lang/reflect/Method;

.field private static ms_oMethod_stopForeground:Ljava/lang/reflect/Method;


# direct methods
.method static constructor <clinit>()V
    .locals 2

    .prologue
    const/4 v1, 0x0

    .line 33
    const/4 v0, 0x0

    sput-boolean v0, Lcom/glympse/platform/Reflection$_Service;->ms_fLoaded:Z

    .line 34
    sput-object v1, Lcom/glympse/platform/Reflection$_Service;->ms_oMethod_setForeground:Ljava/lang/reflect/Method;

    .line 35
    sput-object v1, Lcom/glympse/platform/Reflection$_Service;->ms_oMethod_startForeground:Ljava/lang/reflect/Method;

    .line 36
    sput-object v1, Lcom/glympse/platform/Reflection$_Service;->ms_oMethod_stopForeground:Ljava/lang/reflect/Method;

    .line 31
    return-void
.end method

.method public constructor <init>()V
    .locals 0

    .prologue
    .line 31
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method private static Load()V
    .locals 6

    .prologue
    const/4 v2, 0x1

    .line 41
    sget-boolean v1, Lcom/glympse/platform/Reflection$_Service;->ms_fLoaded:Z

    if-nez v1, :cond_1

    .line 43
    sput-boolean v2, Lcom/glympse/platform/Reflection$_Service;->ms_fLoaded:Z

    .line 48
    :try_start_0
    const-class v1, Landroid/app/Service;

    const-string v2, "startForeground"

    const/4 v3, 0x2

    new-array v3, v3, [Ljava/lang/Class;

    const/4 v4, 0x0

    sget-object v5, Ljava/lang/Integer;->TYPE:Ljava/lang/Class;

    aput-object v5, v3, v4

    const/4 v4, 0x1

    const-class v5, Landroid/app/Notification;

    aput-object v5, v3, v4

    invoke-virtual {v1, v2, v3}, Ljava/lang/Class;->getMethod(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;

    move-result-object v1

    sput-object v1, Lcom/glympse/platform/Reflection$_Service;->ms_oMethod_startForeground:Ljava/lang/reflect/Method;

    .line 49
    const-class v1, Landroid/app/Service;

    const-string v2, "stopForeground"

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/Class;

    const/4 v4, 0x0

    sget-object v5, Ljava/lang/Boolean;->TYPE:Ljava/lang/Class;

    aput-object v5, v3, v4

    invoke-virtual {v1, v2, v3}, Ljava/lang/Class;->getMethod(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;

    move-result-object v1

    sput-object v1, Lcom/glympse/platform/Reflection$_Service;->ms_oMethod_stopForeground:Ljava/lang/reflect/Method;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_1

    .line 56
    :goto_0
    sget-object v1, Lcom/glympse/platform/Reflection$_Service;->ms_oMethod_startForeground:Ljava/lang/reflect/Method;

    if-eqz v1, :cond_0

    sget-object v1, Lcom/glympse/platform/Reflection$_Service;->ms_oMethod_stopForeground:Ljava/lang/reflect/Method;

    if-nez v1, :cond_1

    .line 60
    :cond_0
    :try_start_1
    const-class v1, Landroid/app/Service;

    const-string v2, "setForeground"

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/Class;

    const/4 v4, 0x0

    sget-object v5, Ljava/lang/Boolean;->TYPE:Ljava/lang/Class;

    aput-object v5, v3, v4

    invoke-virtual {v1, v2, v3}, Ljava/lang/Class;->getMethod(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;

    move-result-object v1

    sput-object v1, Lcom/glympse/platform/Reflection$_Service;->ms_oMethod_setForeground:Ljava/lang/reflect/Method;
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    .line 68
    :cond_1
    :goto_1
    return-void

    .line 62
    :catch_0
    move-exception v1

    move-object v0, v1

    .line 64
    .local v0, e:Ljava/lang/Exception;
    invoke-static {v0}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/Throwable;)V

    goto :goto_1

    .line 51
    .end local v0           #e:Ljava/lang/Exception;
    :catch_1
    move-exception v1

    goto :goto_0
.end method

.method public static startForeground(Landroid/app/Service;ILandroid/app/Notification;)V
    .locals 5
    .parameter "oService"
    .parameter "id"
    .parameter "notification"

    .prologue
    .line 73
    if-eqz p0, :cond_0

    .line 75
    invoke-static {}, Lcom/glympse/platform/Reflection$_Service;->Load()V

    .line 80
    :try_start_0
    sget-object v1, Lcom/glympse/platform/Reflection$_Service;->ms_oMethod_startForeground:Ljava/lang/reflect/Method;

    if-eqz v1, :cond_1

    sget-object v1, Lcom/glympse/platform/Reflection$_Service;->ms_oMethod_stopForeground:Ljava/lang/reflect/Method;

    if-eqz v1, :cond_1

    .line 82
    const-string v1, "Calling newer Service.startForeground()"

    invoke-static {v1}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/String;)V

    .line 83
    sget-object v1, Lcom/glympse/platform/Reflection$_Service;->ms_oMethod_startForeground:Ljava/lang/reflect/Method;

    const/4 v2, 0x2

    new-array v2, v2, [Ljava/lang/Object;

    const/4 v3, 0x0

    invoke-static {p1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x1

    aput-object p2, v2, v3

    invoke-virtual {v1, p0, v2}, Ljava/lang/reflect/Method;->invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;

    .line 98
    :cond_0
    :goto_0
    return-void

    .line 87
    :cond_1
    sget-object v1, Lcom/glympse/platform/Reflection$_Service;->ms_oMethod_setForeground:Ljava/lang/reflect/Method;

    if-eqz v1, :cond_0

    .line 89
    const-string v1, "Calling older Service.setForeground(true)"

    invoke-static {v1}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/String;)V

    .line 90
    sget-object v1, Lcom/glympse/platform/Reflection$_Service;->ms_oMethod_setForeground:Ljava/lang/reflect/Method;

    const/4 v2, 0x1

    new-array v2, v2, [Ljava/lang/Object;

    const/4 v3, 0x0

    const/4 v4, 0x1

    invoke-static {v4}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v4

    aput-object v4, v2, v3

    invoke-virtual {v1, p0, v2}, Ljava/lang/reflect/Method;->invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 93
    :catch_0
    move-exception v1

    move-object v0, v1

    .line 95
    .local v0, e:Ljava/lang/Exception;
    invoke-static {v0}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/Throwable;)V

    goto :goto_0
.end method

.method public static stopForeground(Landroid/app/Service;Z)V
    .locals 5
    .parameter "oService"
    .parameter "removeNotification"

    .prologue
    .line 103
    if-eqz p0, :cond_0

    .line 105
    invoke-static {}, Lcom/glympse/platform/Reflection$_Service;->Load()V

    .line 110
    :try_start_0
    sget-object v1, Lcom/glympse/platform/Reflection$_Service;->ms_oMethod_startForeground:Ljava/lang/reflect/Method;

    if-eqz v1, :cond_1

    sget-object v1, Lcom/glympse/platform/Reflection$_Service;->ms_oMethod_stopForeground:Ljava/lang/reflect/Method;

    if-eqz v1, :cond_1

    .line 112
    const-string v1, "Calling newer Service.stopForeground()"

    invoke-static {v1}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/String;)V

    .line 113
    sget-object v1, Lcom/glympse/platform/Reflection$_Service;->ms_oMethod_stopForeground:Ljava/lang/reflect/Method;

    const/4 v2, 0x1

    new-array v2, v2, [Ljava/lang/Object;

    const/4 v3, 0x0

    invoke-static {p1}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v4

    aput-object v4, v2, v3

    invoke-virtual {v1, p0, v2}, Ljava/lang/reflect/Method;->invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;

    .line 128
    :cond_0
    :goto_0
    return-void

    .line 117
    :cond_1
    sget-object v1, Lcom/glympse/platform/Reflection$_Service;->ms_oMethod_setForeground:Ljava/lang/reflect/Method;

    if-eqz v1, :cond_0

    .line 119
    const-string v1, "Calling older Service.setForeground(false)"

    invoke-static {v1}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/String;)V

    .line 120
    sget-object v1, Lcom/glympse/platform/Reflection$_Service;->ms_oMethod_setForeground:Ljava/lang/reflect/Method;

    const/4 v2, 0x1

    new-array v2, v2, [Ljava/lang/Object;

    const/4 v3, 0x0

    const/4 v4, 0x0

    invoke-static {v4}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v4

    aput-object v4, v2, v3

    invoke-virtual {v1, p0, v2}, Ljava/lang/reflect/Method;->invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 123
    :catch_0
    move-exception v1

    move-object v0, v1

    .line 125
    .local v0, e:Ljava/lang/Exception;
    invoke-static {v0}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/Throwable;)V

    goto :goto_0
.end method
